from django.shortcuts import get_object_or_404, render
from django.contrib.auth.decorators import login_required
from django.http import *
from app.luca_template.models import Template
from app.luca_customer.models import Customer
from common.util.fiboapi import *

@login_required(redirect_field_name=None)           
def sms_new(request):
    templates_list = Template.objects.filter(active=1).order_by('-id')
        
    context = {'templates_list': templates_list}
    return render(request, 'sms_new.html',context)


def sms_ajax_template(request):
    id = request.GET['id']
    template = Template.objects.get(id=int(id))
    name=template.content
    return HttpResponse(name)
    
def sms_ajax_submit(request):
    result=smsSendMaskedSMS(request.GET['telephone'],request.GET['template_content'])
    #result=smsGetClientBalance()
    return HttpResponse(result)
    

